
R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> # this creates some indicator variables and other data sets needed
> # Last updated Apr 13, 2022
> library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✔ ggplot2 3.3.5     ✔ purrr   0.3.4
✔ tibble  3.1.6     ✔ dplyr   1.0.7
✔ tidyr   1.1.4     ✔ stringr 1.4.0
✔ readr   2.1.0     ✔ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
> library(here)
here() starts at /Users/elisha/Dropbox/current-research/Glynn - Race and Policing/Papers/Published Papers/JOP_RacialBias
> ### load data -------
> ois <- readRDS(here('data','ois.RDS'))
> 
> #create binary fatal variable
> ois$fatal <- ifelse(ois$civilian_fatality=='Fatal',1,0)
> ois$fatal <- ifelse(ois$civilian_fatality %in% c('Undetermined','Unknown'),NA,ois$fatal)
> #order race variable
> ois$civilian_race_factor <- factor(ois$civilian_race_new, 
+                                    levels = c("White", "Black", "Hispanic","Asian/AI/AN/PI"))
> 
> ## all cities and include year variable -------
> orig <- ois %>% 
+   filter(!is.na(fatal)) %>%
+   #filter(civilian_race_factor %in% c("White","Black")) %>%
+   select(city_clean, civilian_race_factor,fatal, year,closesttraumamiles,new_group_id)
> 
> # Make city dummies
> orig <- orig %>%
+   mutate(Houston = ifelse(city_clean=='Houston',1,0),
+          King_County = ifelse(city_clean == 'King County',1,0),
+          Los_Angeles = ifelse(city_clean == 'Los Angeles',1,0),
+          Orlando = ifelse(city_clean == 'Orlando',1,0),
+          San_Antonio = ifelse(city_clean == 'San Antonio',1,0),
+          San_Jose = ifelse(city_clean == 'San Jose',1,0),
+          Seattle = ifelse(city_clean == 'Seattle',1,0),
+          Tucson = ifelse(city_clean == 'Tucson',1,0),
+          Charlotte = ifelse(city_clean == 'Charlotte',1,0))
> # Make Race dummies
> orig <- orig %>%
+   mutate(White = ifelse(civilian_race_factor == 'White', 1, 0),
+          Black = ifelse(civilian_race_factor == 'Black', 1, 0),
+          Hispanic = ifelse(civilian_race_factor == 'Hispanic', 1, 0),
+          Asian = ifelse(civilian_race_factor == 'Asian/AI/AN/PI', 1, 0))
> 
> # re-scale distance variable
> orig$trauma10 <- orig$closesttraumamiles / 10
> 
> orig$city_factor <- factor(orig$city_clean,
+                            levels = c("Charlotte","Houston","King County",
+                                       "Los Angeles","Orlando",
+                                       "San Jose","Seattle","Tucson"))
> orig$city_factor <- relevel(orig$city_factor, ref="Charlotte")
> levels(orig$city_factor)
[1] "Charlotte"   "Houston"     "King County" "Los Angeles" "Orlando"    
[6] "San Jose"    "Seattle"     "Tucson"     
> # Make subsets of data -----
> orig_bl_wh <- orig %>% filter(civilian_race_factor == "White" |
+                                 civilian_race_factor == "Black")
> 
> orig_hisp_wh <- orig %>% filter(civilian_race_factor == "White" |
+                                   civilian_race_factor == "Hispanic")
> 
> orig_asian_wh <- orig %>% filter(civilian_race_factor == "White" |
+                                    civilian_race_factor == "Asian/AI/AN/PI")
> 
> save(orig,orig_bl_wh,orig_hisp_wh,orig_asian_wh,ois,
+      file = here("data","ois_data_for_models.RData"))
> 
> proc.time()
   user  system elapsed 
 14.270   0.457  15.181 
